using Google.Protobuf.Collections;
using Map;
using System;

public class RoomInfoData : IDataModel<RoomInfoData,Map.RoomBrief,int>
{
    public int roomId;
    public string roomName;
    public bool hasPassword;
    public int playerCount;
    public int roomState;

    public int Key => roomId;

    public bool Equals(RoomBrief p)
    {
        return p.RoomId == roomId;
    }

    public bool Equals(int l, int r)
    {
        return l == r;
    }

    public int KeyOf(RoomBrief p)
    {
        return p.RoomId;
    }

    public bool LessThan(RoomInfoData other)
    {
        return roomId < other.roomId;
    }

    public void Reset()
    {
        roomId = 0;
        roomName = string.Empty;
        hasPassword = false;
        playerCount = 0;
        roomState = 0;
    }

    public void Set(global::Map.RoomBrief brief)
    {
        roomId = brief.RoomId;
        roomName = brief.RoomName;
        hasPassword = brief.HasPassword;
        playerCount = brief.PlayerCount;
        roomState = brief.RoomState;
    }
}

public class RoomManager : DataModelSingleton<RoomManager, RoomInfoData, Map.RoomBrief, int>
{
    public override int ID => CtrlEventID.ROOM_MANAGER_ID;
    protected override Func<IDataModelCenter<RoomInfoData, RoomBrief, int>> DataModelCreator => AsList(() => new RoomInfoData(), ID);
}
